<?php
/* Web Statistics and Analytics Console (PHP)
 *  subpages/master-header.php
 *  Author: Trevor Bidyk
 *  Created: January 1, 2000
 *  Last modified: April 4, 2011
 *   (C) Us 2011
 *   Uses Simple PHP Framework, licensed under the FreeBSD license.
 *    View license in ./include/LICENSE.
 *   All rights reserved.
 */
$NavigationTree = array(
    0 => array(
        'ID' => 'index',
        'Name' => 'Dashboard',
        'URL' => 'index.php',
        'Subtree' => null),
    1 => array(
        'ID' => 'stats',
        'Name' => 'View Statistics',
        'URL' => 'view_stats.php',
        'Subtree' => array(
            0 => array(
                'ID' => 'events',
                'Name' => 'Event Statistics',
                'URL' => 'do=events'))),
    2 => array(
        'ID' => 'generate',
        'Name' => 'Generate Data',
        'URL' => 'generate_data.php',
        'Subtree' => array(
            0 => array(
                'ID' => 'generate',
                'Name' => 'Generate Data',
                'URL' => 'do=generate'),
            1 => array(
                'ID' => 'clear',
                'Name' => 'Clear Data',
                'URL' => 'do=clear'))),
    3 => array(
        'ID' => 'scripts',
        'Name' => 'View Scripts',
        'URL' => 'view_scripts.php',
        'Subtree' => array(
            0 => array(
                'ID' => 'scripts',
                'Name' => 'View Scripts',
                'URL' => ''),
            1 => array(
                'ID' => 'JS',
                'Name' => 'Download JS',
                'URL' => 'download=js'),
            2 => array(
                'ID' => 'ZIP',
                'Name' => 'Download ZIP',
                'URL' => 'download=zip'),
            3 => array(
                'ID' => 'tar',
                'Name' => 'Download TAR',
                'URL' => 'download=tar'))),
    4 => array(
        'ID' => 'logout',
        'Name' => 'Logout',
        'URL' => 'user.php?do=logout',
        'Subtree' => null));

$NavigationLinks = '';
$SubNavigationLinks = '';
foreach ($NavigationTree as $Node) {
    if ($Node['ID'] == $CurrentPage) {
        $NavigationLinks .= "\t\t\t<li class=\"active\">" . $Node['Name'] . "</li>\n";
        if (is_array($Node['Subtree'])) {
            foreach ($Node['Subtree'] as $SubNode) {
                if ($SubNode['ID'] == $CurrentSubPage) {
                    $SubNavigationLinks .= "\t\t\t<li class=\"active\">" . $SubNode['Name'] . "</li>\n";
                } else {
                    $SubNavigationLinks .= "\t\t\t<li><a href=\"" . $Node['URL'] . '?' . $SubNode['URL'] . '">' . $SubNode['Name'] . "</a></li>\n";
                }
            }
        }
    } else {
        $NavigationLinks .= "\t\t\t<li><a href=\"" . $Node['URL'] . '">' . $Node['Name'] . "</a></li>\n";
    }
}
$Auth = &$GLOBALS['Auth'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <title>Web Statistics and Analytics Console</title>
        <link href="style/style.css" rel="stylesheet" type="text/css" />
        <link rel="shortcut icon" href="./style/icon.png" />
    </head>
    <body>
        <div id="aac-header">
            <div id="interior">
                <div id="title"><span>Web Statistics and Analytics Console</span></div>
                <div id="current-time"><span><?php echo date("H:m F, j Y"); ?></span></div>
                <div id="current-user"><span>Logged in as <em><?php echo $Auth->user->username; ?></em></span></div>

            </div>
        </div>
        <div id="aac-navigation">
            <ul>
<?php echo $NavigationLinks;?>
            </ul>
        </div>
        <div id="content">
            <div id="aac-subnavigation">
                <ul>
<?php echo $SubNavigationLinks;?>
                </ul>
            </div>
<!-- /master-header -->